What is causing the Uncaught SyntaxError: Unexpected token '}' in my JavaScript code